package action;

/**
 * 
 * @author Ygor
 * 
 */
public class PeriodicMovement {
	private double innerCount; // angle to the sin function.
	private double innerTime; // tempo que ele passou processando..
	private float amp;
	private float time;

	public PeriodicMovement(float amplitude, float time) {
		innerCount = 0;
		innerTime = 0;
		this.amp = amplitude;
		this.time = time;
	}

	public double Update(Double input, Double elapsedTime) {
		if (innerTime >= time) {
			innerTime = 0;
		}
		innerCount += 0.1;
		innerCount %= 2 * Math.PI;
		innerTime += elapsedTime;
		innerCount = ((innerTime * 360) / time) * Math.PI / 180;
		return input + (amp * Math.sin(innerCount));
	}

	/**
	 * @return the innerCount
	 */
	public double getInnerCount() {
		return innerCount;
	}

	/**
	 * @param innerCount
	 *            the innerCount to set
	 */
	public void setInnerCount(double innerCount) {
		this.innerCount = innerCount;
	}

	/**
	 * @return the amp
	 */
	public float getAmp() {
		return amp;
	}

	/**
	 * @param amp
	 *            the amp to set
	 */
	public void setAmp(float amp) {
		this.amp = amp;
	}

	/**
	 * @return the period
	 */
	public float getTime() {
		return time;
	}

	/**
	 * @param period
	 *            the period to set
	 */
	public void setPeriod(float time) {
		this.time = time;
	}

}
